package com.taniurakengo.sourceviewer;

import java.util.ArrayList;
import java.util.List;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

/**
 * 
 * @author Taniura
 *
 */
public class CustomFragmentPagerAdapter extends FragmentPagerAdapter {

	//
	private List<String> items;
	private String currentpath;
	
	public void setitems(List<String> _items) {
		items = new ArrayList<String>(_items); 
	}
	
	public void setCurrentpath(String currentpath) {
		this.currentpath = currentpath;
	}

	/**
	 * 
	 * @param fm
	 */
	public CustomFragmentPagerAdapter(FragmentManager fm) {
		super(fm);
	}

	/**
	 * 
	 */
	@Override
	public Fragment getItem(int position) {

		String summary = String.format("%s/%s", 
				String.valueOf(position+1), 
				String.valueOf(items.size()));

		Fragment fragment = WebViewFragment.newInstance(items.get(position), summary, currentpath);
		
		return fragment;
		
	}

	/**
	 * 
	 */
	@Override
	public int getCount() {
		return items.size();
	}


	
}
